// pages/activity/select-success/index.js
const app = getApp();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        loadStatus: false,
        id: '',
        detail: {},
        showShareType: false,
        shareConfig: false
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
      // options.id = 1;
      this.setData({
        id: options.id
      })
        wx.showLoading();
        this.get_detail(() => {
          this.setData({
            loadStatus: true
          })
            wx.hideLoading();
        })
    },

   
    onShareAppMessage: function() {
        let userInfo = wx.getStorageSync('userinfo');
        return {
            title: this.data.detail.name,
            imageUrl: this.data.detail.cover_image,
            path: 'pages/activity/enrollment/index?id=' + this.data.detail.id + '&uid=' + userInfo.loginUid
        }
    },
    //获取详情信息
    get_detail(callback) {
        let that = this;
        app.request({
            url: 'enrollment/order',
            data: {
                id: that.data.id
            },
            sCallback: (res) => {
                if (res.code == 1) {
                    that.setData({
                        detail: res.data
                    })
                    callback && callback();
                } else if(res.code == 2){
                    wx.redirectTo({
                        url: '/pages/activity/select-school/index?id='+that.data.id
                    })
                } else {
                    app.alert(res.msg, () => {
                        wx.navigateBack();
                    })
                }
            }
        })
    },
})